<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
      xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head th:include="include :: header"></head>
<body class="hold-transition skin-blue sidebar-mini">

<section class="content-header">
    <h1>变更提醒</h1>
</section>
<section class="content">
    <div class="row">
        <div class="col-xs-12">
            <div class="box">
                <div class="box-header">
                    <form id="queryForm" onsubmit="return false;">
                        <div class="row">
                            <div class="form-inline">
                                <div class="form-group">
                                    <label for="query-proCode">项目编号</label>
                                    <input id="query-proCode" type="text" name="proCode" class="form-control"
                                           placeholder="请输入项目编号">
                                </div>
                                <div class="form-group">
                                    <label for="query-proName">项目名称</label>
                                    <input id="query-proName" type="text" name="proName" class="form-control"
                                           placeholder="请输入项目名称">
                                </div>
                                <div class="form-group">
                                    <label for="query-special">类型</label>
                                    <select id="query-special" class="form-control" name="special">
                                        <option value="" selected>请选择</option>
                                        <option th:each="type : ${specials}" th:value="${type.name}"
                                                th:text="${type.name}"></option>
                                    </select>
                                </div>
                                <div class="form-group">
                                    <label for="query-part">部分</label>
                                    <input id="query-part" type="text" name="part" class="form-control"
                                           placeholder="请输入部分">
                                </div>
                                <div class="form-group">
                                    <label for="query-drawNo">图号</label>
                                    <input id="query-drawNo" type="text" name="drawNo" class="form-control"
                                           placeholder="请输入图号">
                                </div>
                                <div class="form-group">
                                    <label for="query-changeStatus">状态</label>
                                    <select id="query-changeStatus" class="form-control" name="changeStatus">
                                        <option value="">请选择</option>
                                        <option value="0" selected>未处理</option>
                                        <option value="1">已处理</option>
                                    </select>
                                </div>
                                <!--<div class="form-group">
                                    <label for="query-isCheck">审核状态</label>
                                    <select id="query-isCheck" class="form-control" name="isCheck">
                                        <option value="" selected>请选择</option>
                                        <option value="0">未审核</option>
                                        <option value="1">已审核</option>
                                    </select>
                                </div>-->
                                <!--<div class="form-group">
                                    <label for="query-createName">工艺员</label>
                                    <input id="query-createName" type="text" name="createName" class="form-control"
                                           placeholder="请输入工艺员">
                                </div>
                                <div class="form-group">
                                    <label for="query-branchName">工艺科室</label>
                                    <input id="query-branchName" type="text" name="branchName" class="form-control"
                                           placeholder="请输入工艺科室">
                                </div>-->
                                <div class="form-group">
                                    <label for="query-startTime">日期</label>
                                    <input id="query-startTime" type="text" class="form-control datepicker"
                                           name="startTime"
                                           readonly="readonly"/>
                                    <label for="query-endTime"> 至 </label>
                                    <input id="query-endTime" type="text" class="form-control datepicker" name="endTime"
                                           readonly="readonly"/>
                                </div>
                                <button type="button" class="btn btn-success" id="btn-search"
                                        onclick="js.table.search(table)">
                                    <span class="Bold">搜索</span>
                                </button>
                            </div>
                        </div>
                    </form>
                </div>
                <div class="box-body">
                    <table id="bootstrap-table"></table>
                </div>
            </div>
        </div>
    </div>
</section>
<div th:include="include :: footer"></div>
<script th:inline="javascript">

    let table;

    /** 同意操作 */
    function handler(id) {
        js.modal.confirm("确认完结吗？", function () {
            js.post({
                url: ctx + "est/cha/handler",
                data: {id: id},
                success: function (result) {
                    if (result.type === web_status.SUCCESS) {
                        js.modal.success(result.msg);
                        js.table.refresh(table);
                    } else {
                        js.modal.warning(result.msg);
                    }
                }
            })
        })
    }

    $(function () {

        /** 主表 */
        table = js.table.init({
            url: ctx + "est/cha/list",
            showExport: false,
            columns: [
                {
                    title: '序号', field: 'id', width: '50',
                    formatter: function (value, row, index) {
                        return index + 1;
                    }
                },
                {title: "项目编号", field: 'proCode'},
                {title: "项目名称", field: 'proName'},
                {title: "项目数量", field: 'proNum'},
                {title: "类型", field: 'special'},
                {title: "部分", field: 'part'},
                {title: "图号", field: 'drawNo'},
                {title: "图名", field: 'drawName'},
                {title: "制作件<br>类型", field: 'makeType'},
                {title: "设计科室", field: 'sectionName'},
                {
                    title: "变更<br>单据类型", field: 'changeType',
                    formatter: function (value, row, index) {
                        if (row.detailPid != null) {
                            return '拆分修改'
                        }
                        if (value === 1) {
                            return '图纸变更'
                        } else if (value === 2) {
                            return '清单变更'
                        } else if (value === 3) {
                            return '清单和图纸变更'
                        }
                    }
                },
                {
                    title: "变更<br>类型", field: 'technologyChange',
                    formatter: function (value, row, index) {
                        if (value === 1) {
                            return '修改'
                        } else if (value === 2) {
                            return '删除'
                        } else if (value === 3) {
                            return '新增'
                        }
                    }
                },
                // {title: "设计者", field: ''},
                {title: "变更日期", field: 'lastTime'},
                {title: "工艺卡<br>创建人", field: 'createNameOne'},
                // {title: "设计变更量", field: ''},
                // {title: "工艺科室", field: 'deptName'},
                // {title: "完结状态", field: 'changeStatus'},
                // {title: "工艺员", field: 'checkNames'},
                {
                    title: "操作",
                    // width: '160px',
                    formatter: function (value, row) {
                        let actions = [];
                        if ((row.changeType === 1 || row.changeType === 3) && (row.detailPid == null)) {
                            actions.push('<a class="btn btn-info btn-xs" target="_blank" href="' + ctx + 'est/cha/info2/' + row.resultId + '" > 图纸查看</a>');
                        }
                        if (row.changeType > 1 && (row.detailPid == null)) {
                            actions.push('<a class="btn btn-info btn-xs" target="_blank" href="' + ctx + 'est/cha/info/' + row.resultId + '" > 清单查看</a>');
                        }
                        /*if (hasP("est:cha:edit") && row.cardStatus === 5) {
                            actions.push('<a class="btn btn-warning btn-xs" target="_blank" href="' + ctx + 'est/cha/edit/' + row.cardId + '" > 变更</a>');
                        }*/
                        if (hasP("est:cha:edit")) {
                            actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="handler(' + row.makeDetailId + ')"> 处理</a>');
                        }

                        return actions.join('');
                    }
                }
            ]
        });

    });
</script>
</body>
</html>
